﻿<UserControl x:Class="MultiTouch.Behaviors.Silverlight4.Sample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:behaviors="clr-namespace:MultiTouch.Behaviors.Silverlight4;assembly=MultiTouch.Behaviors.Silverlight4" 
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Canvas x:Name="LayoutRoot">
        <Canvas.Background>
            <ImageBrush ImageSource="Images/WindowBackground.jpg"/>
        </Canvas.Background>

            <!-- Behavior for this item is attached in code-behind-->
            <Image x:Name="item1" Source="Images/Desert.jpg" Width="200">

            </Image>
            
            <Image x:Name="item2" Source="Images/Hydrangeas.jpg" Width="200">
                <interactivity:Interaction.Behaviors>
                    <behaviors:MultiTouchBehavior IsRotateEnabled="True" IsScaleEnabled="True" 
                                                  IsTranslateXEnabled="True" 
                                                  IsTranslateYEnabled="True" 
                                                  IsPivotEnabled="False"/>
                </interactivity:Interaction.Behaviors>
            </Image>
            <Button Canvas.Left="6" Canvas.Top="6" Content="Attach Behavior" Height="23" Name="btnAttach" Width="103" Click="btnAttach_Click" Canvas.ZIndex="9999"/>
            <Button Canvas.Left="6" Canvas.Top="35" Content="Detach Behavior" Height="23" Name="btnDetach" Width="103" Click="btnDetach_Click" Canvas.ZIndex="9999"/>

            <Image x:Name="item3" Source="{Binding SelectedPicture}" Width="200">
                <interactivity:Interaction.Behaviors>
                    <behaviors:MultiTouchBehavior IsRotateEnabled="True" IsScaleEnabled="True" IsTranslateXEnabled="True" 
                                                  IsTranslateYEnabled="True" IsInertiaEnabled="True"
                                                  MinimumScale="5" MaximumScale="200"
                                                  AreFingersVisible="True"/>
                </interactivity:Interaction.Behaviors>
            </Image>

            <!-- A list of available Images -->
            <ListBox x:Name="lstImages" Width="100" Canvas.Left="10" Canvas.Top="200"
                         ItemsSource="{Binding Pictures}" SelectedItem="{Binding SelectedPicture, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding}" Width="50"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>             
            </ListBox>
    </Canvas>
</UserControl>
